package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.SickArea;
import com.ruoyi.manage.service.ISickAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 病区，一般对接第三方Controller
 * 
 * @author liuyangyang
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/manage/sickarea")
public class SickAreaController extends BaseController
{
    @Autowired
    private ISickAreaService sickAreaService;

    /**
     * 查询病区，一般对接第三方列表
     */
    @PreAuthorize("@ss.hasPermi('manage:sickarea:list')")
    @GetMapping("/list")
    public TableDataInfo list(SickArea sickArea)
    {
        startPage();
        List<SickArea> list = sickAreaService.selectSickAreaList(sickArea);
        return getDataTable(list);
    }

    /**
     * 导出病区，一般对接第三方列表
     */
    @PreAuthorize("@ss.hasPermi('manage:sickarea:export')")
    @Log(title = "病区，一般对接第三方", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SickArea sickArea)
    {
        List<SickArea> list = sickAreaService.selectSickAreaList(sickArea);
        ExcelUtil<SickArea> util = new ExcelUtil<SickArea>(SickArea.class);
        util.exportExcel(response, list, "病区，一般对接第三方数据");
    }

    /**
     * 获取病区，一般对接第三方详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:sickarea:query')")
    @GetMapping(value = "/{sickAreaId}")
    public AjaxResult getInfo(@PathVariable("sickAreaId") Long sickAreaId)
    {
        return success(sickAreaService.selectSickAreaBySickAreaId(sickAreaId));
    }

    /**
     * 新增病区，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:sickarea:add')")
    @Log(title = "病区，一般对接第三方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SickArea sickArea)
    {
        return toAjax(sickAreaService.insertSickArea(sickArea));
    }

    /**
     * 修改病区，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:sickarea:edit')")
    @Log(title = "病区，一般对接第三方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SickArea sickArea)
    {
        return toAjax(sickAreaService.updateSickArea(sickArea));
    }

    /**
     * 删除病区，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:sickarea:remove')")
    @Log(title = "病区，一般对接第三方", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sickAreaIds}")
    public AjaxResult remove(@PathVariable Long[] sickAreaIds)
    {
        return toAjax(sickAreaService.deleteSickAreaBySickAreaIds(sickAreaIds));
    }
}
